/**
 * 
 */
package com.holystone.orca.sys.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.holystone.orca.sys.mybatis.dao.SysRoleMapper;
import com.holystone.orca.sys.mybatis.dao.SysStaffRoleMapper;
import com.holystone.orca.sys.mybatis.model.SysRole;
import com.holystone.orca.sys.service.IStaffRoleService;

/**
 * Copyright (c) 2015, HOLYSTONE Technologies, Inc.
 * All right reserved.
 * @desc:
 * @author:王凯征
 * @date:2015年11月9日 下午8:35:59
 */
@Service(value="StaffRoleService")
@Transactional
public class StaffRoleServiceImpl implements IStaffRoleService{
	@Autowired
	private SysRoleMapper sysRoleMapper;
	
	@Autowired
	private SysStaffRoleMapper staffRoleMapper;
	
	public List<SysRole> getStaffRoleList(Integer staffId){
		Map<String, String> map=new HashMap<String, String>();
		map.put("staffId", staffId.toString());
		//map.put("roleState",SystemConstant.PRI_STATE_A );

		List<SysRole> list = sysRoleMapper.getStaffRoleList(map);
		return list;
	}

	@Override
	public boolean insertStaffRole(String roleName) {
		
		int result=staffRoleMapper.insertStaffRole(roleName);
		if(result==1){
			return true;
		}else{
			return false;
		}
	}

	@Override
	public boolean updateStaffRoleByPersonId(Map<Object, String> map) {
		int result=staffRoleMapper.updateStaffRoleByPersonId(map);
		if(result==1){
			return true;
		}else{
			return false;
		}
	}

	@Override
	public boolean deleteStaffRoleByPersonId(int personId) {
		int result=staffRoleMapper.deleteStaffRoleByPersonId(personId);
		if(result==1){
			return true;
		}else{
			return false;
		}
	}

	@Override
	public boolean delSelectStaffRole(List<Integer> list) throws Exception {
		int result=staffRoleMapper.delSelectStaffRole(list);
		if(result==list.size()){
			return true;
		}else{
			return false;
		}
	}
}
